package com.yj.web.dao.mapper;

import com.yj.web.dao.po.admin.Role;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface RoleMapper {
    @Insert("insert into role (number, role) values (#{role.number}, #{role.role})")
    @Options(useGeneratedKeys = true, keyProperty = "role.id")
    public long insert(@Param("role") Role role);

    @Select("select * from role where deleted = 0 order by id desc")
    public List<Role> listRole();

    @Select("select count(*) from role where deleted = 0")
    public int count();

    @Select("select * from role where number = #{number} and deleted = 0")
    public Role selectRoleByNumber(@Param("number") int number);
}
